package com.wss.module.wan.ui.series.adapter;

import com.wss.common.base.adapter.BaseListAdapter;
import com.wss.common.base.adapter.listener.OnListItemClickListener;
import com.wss.common.base.adapter.superadapter.SuperViewHolder;
import com.wss.common.utils.ColorUtils;
import com.wss.module.wan.ResourceTable;
import com.wss.module.wan.bean.ClassificationChild;
import ohos.agp.components.Text;
import ohos.app.Context;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * Describe：体系子级适配器
 * Created by 吴天强 on 2018/11/15.
 */
public class SetupRightAdapter extends BaseListAdapter<ClassificationChild> {

    private int selectIndex;
    private Context context;

    public SetupRightAdapter(Context context, List<ClassificationChild> items, OnListItemClickListener<ClassificationChild> listener) {
        super(context, items, ResourceTable.Layout_wan_item_of_setup_list, listener);
    }

    public void notifyData(int selectIndex) {
        this.selectIndex = selectIndex;
        notifyDataChanged();
    }

    @Override
    public void onBindData(@NotNull SuperViewHolder holder, int layoutPosition, @NotNull ClassificationChild data) {
        Text textView = holder.findViewById(ResourceTable.Id_tv_text);
        textView.setText(data.getName());
        if (layoutPosition == selectIndex) {
            textView.setTextColor(ColorUtils.colorResToColor(context, ResourceTable.Color_white));
            textView.setBackground(ColorUtils.colorResToElement(context, ResourceTable.Color_orange));
        } else {
            textView.setTextColor(ColorUtils.colorResToColor(context, ResourceTable.Color_black));
            textView.setBackground(ColorUtils.colorResToElement(context, ResourceTable.Color_transparent));
        }
    }
}
